package cn.fx.operation._02_xhr;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer("jklw_uuuu_group");

        producer.setNamesrvAddr("localhost:9876");

        producer.start();

        Message message = new Message("jklw", "kkkk", "将发挥更好发挥".getBytes(StandardCharsets.UTF_8));

        producer.send(message, new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                System.out.println("消息成功消费" + sendResult.toString());
            }

            @Override
            public void onException(Throwable throwable) {
                throwable.printStackTrace();
                System.out.println("消息消费失败");
            }
        });
    }
}
